package com.credithc.customers.dataservice.mapper.XHQB;

import com.credithc.customers.dataservice.po.SystemLendPo;
import com.credithc.customers.dataservice.po.SystemUserPo;
import com.credithc.customers.dataservice.po.XhqbDateLine;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface XhqbMapper {


    @Select("select hw_order.user_id  userId ,hw_order.loan_amount amount,hw_order.create_date capitalEffectDate ,hw_order.order_state sts ,hw_order.id incrementId , hw_rate.repayment_type period_type,hw_rate.earlier_periods e_period,hw_rate.later_periods l_period,periods period\n" +
            "             from hw_order LEFT JOIN hw_course_rate on hw_order.course_rate_id = hw_course_rate.course_rate_id\n" +
            "\t\t\t\t\t\t left join hw_rate on hw_course_rate.rate_id = hw_rate.rate_id\n" +
            "\t\t\t       where hw_order.id<#{incrementId} and hw_order.id >= #{incrementId}-1000 \n" +
            "             ORDER BY hw_order.id desc;")
    List<SystemLendPo> queryXhqbLend(@Param("incrementId")String incrementId);

    @Select("select MAX(id)  from hw_order\n ")
    Long queryLendMaxId();
    @Select("select hw_rate.repayment_type,hw_rate.earlier_periods,hw_rate.later_periods,periods from  hw_course_rate \n" +
            "LEFT JOIN hw_rate on hw_course_rate.rate_id = hw_rate.rate_id where hw_course_rate.course_rate_id =#{id}")
    XhqbDateLine queryDeadLine(String id);
    @Select("select MAX(id)  from hw_binded_bank_card\n ")
    Long queryBankMaxId();
    @Select("SELECT hw_binded_bank_card.bankcard_number customerId ,user_id userId ,create_date creatTime\n " +
            " from hw_binded_bank_card  where id <#{toString} and id >#{toString} -1000")
    List<SystemUserPo> queryXhqbBank(String toString);
}
